//
//  RegisterViewController.m
//  02-LaGouRegisterHomeWork
//
//  Created by 曹曹 on 16/7/15.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "RegisterViewController.h"
#import "LoginView.h"

#define SCREEN_WIDTH self.view.frame.size.width

@interface RegisterViewController ()
@property (nonatomic, strong) UIImageView *backgroundImageView;
@property (nonatomic, strong) UIImageView *logoImageView;
@property (nonatomic, strong) UIButton *loginButton;
@property (nonatomic, strong) LoginView *logins;
@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setBackgroundImage];
    [self setLogoImage];
    [self createLoginButton];
    self.logins = [[LoginView alloc] initWithFrame:CGRectMake(14, 350, SCREEN_WIDTH - 28, 89)
                                         imageUser:@"phone"
                                     imagePassword:@"vertification"
                                   placeHolderUser:@"请输入手机号"
                           placeHolderDownPassword:@"请输入验证码"];
    [self.view addSubview:_logins];
    [self createBackLoginButton];
    [self createProtocalView];
}
#pragma mark - 背景
- (void)setBackgroundImage {
    _backgroundImageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"welcome_2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self.view addSubview:_backgroundImageView];
    _backgroundImageView.frame = self.view.frame;
}
#pragma mark - LOGO
- (void)setLogoImage {
    _logoImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_lagou"]];
    [_backgroundImageView addSubview:_logoImageView];
    _logoImageView.frame = CGRectMake(0, 0, 92, 148);
    _logoImageView.center = CGPointMake(SCREEN_WIDTH / 2, 240);
}
#pragma mark - 注册按钮
- (void)createLoginButton {
    _loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [_loginButton setTitle:@"注册" forState:UIControlStateNormal];
    [_loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:_loginButton];
    _loginButton.backgroundColor = [UIColor colorWithRed:0.01 green:0.81 blue:0.53 alpha:1.00];
    _loginButton.frame = CGRectMake(14, 500, SCREEN_WIDTH - 28, 44);
    _loginButton.layer.cornerRadius = 5;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - 返回登录按钮
- (void)createBackLoginButton {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    [button setTitle:@"返回登录" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor colorWithRed:0.01 green:0.74 blue:0.49 alpha:1.00] forState:UIControlStateNormal];
    [self.view addSubview:button];
    button.backgroundColor = [UIColor colorWithRed:0.01 green:0.64 blue:0.49 alpha:0.2];
    button.frame = CGRectMake(14, 550, SCREEN_WIDTH - 28, 44);
    button.layer.cornerRadius = 5;
    button.layer.borderWidth = 1;
    button.layer.borderColor = [UIColor colorWithRed:0.01 green:0.64 blue:0.49 alpha:1.00].CGColor;
    [button addTarget:self action:@selector(handleBackLoginButton:) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - 注册协议
- (void)createProtocalView {
    UIView *protocalView = [[UIView alloc] initWithFrame:CGRectMake(50, 450, 258, 30)];
    UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_password"]];
    iconView.frame = CGRectMake(0, 0, 30, 30);
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 138, 30)];
    label.text = @"注册代表你已同意";
    label.textColor = [UIColor grayColor];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(168, 0, 90, 30);
    [button setTitle:@"拉勾用户协议" forState:UIControlStateNormal];
    button.titleLabel.textAlignment = NSTextAlignmentLeft;
    [button setTitleColor:[UIColor colorWithRed:0.00 green:0.67 blue:0.53 alpha:1.00] forState:UIControlStateNormal];
    [protocalView addSubview:iconView];
    [protocalView addSubview:label];
    [protocalView addSubview:button];
    [self.view addSubview:protocalView];
}
- (void)handleBackLoginButton:(UIButton *)button {
//    [self dismissViewControllerAnimated:YES completion:nil];
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
